import requests
from config import url, headers_web


class CourseChapterGoal:
    def __int__(self):
        self.headers = headers_web
        self.url = url

    @classmethod
    def get_course_chapter_goal(cls, url: str, headers, params):
        """
        @summary:获取章节目标
        @description:云课堂教师端-课程建设使用
        :param url:
        :param headers:
        :param params:{
                        "courseId":"", # 课程id
                        "structureId":"", # 章节id
                        "validCode":"", # &signKey=123123
                        "versionId":"" # 版本id
                        }
        :return:object:[
                {
                    "structureShowOrder": 0,
                    "structureId": "",
                    "structureName": "",
                    "goalList": [
                        {
                            "typeName": "概述",
                            "typeValue": 0,
                            "parentName": "教学目标",
                            "isShow": false,
                            "showOrder": 0,
                            "content": null
                        },
                        {
                            "typeName": "知识",
                            "typeValue": 1,
                            "parentName": "教学目标",
                            "isShow": true,
                            "showOrder": 1,
                            "content": null
                        },
                        {
                            "typeName": "能力",
                            "typeValue": 2,
                            "parentName": "教学目标",
                            "isShow": true,
                            "showOrder": 2,
                            "content": null
                        },
                        {
                            "typeName": "思政目标",
                            "typeValue": 3,
                            "parentName": "教学目标",
                            "isShow": true,
                            "showOrder": 3,
                            "content": null
                        },
                        {
                            "typeName": "概述",
                            "typeValue": 4,
                            "parentName": "考核办法",
                            "isShow": false,
                            "showOrder": 4,
                            "content": null
                        }
                    ]
                }
            ]
        """
        url = url + "/courseApi/v1/coursechaptergoal"

        r = requests.get(url=url, headers=headers, params=params)

        return r

    @classmethod
    def post_add_course_chapter_goal(cls, url: str, headers, params, json):
        """
        @summary:新增课程章节目标
        @description:云课堂教师端-课程建设使用
        :param url:
        :param headers:
        :param params:validCode:&signKey=123123
        :param json:{
                    "structureShowOrder": 0,
                    "structureId": "",
                    "structureName": "",
                    "goalList": [
                        {
                            "typeName": "概述",
                            "typeValue": 0,
                            "parentName": "教学目标",
                            "isShow": false,
                            "showOrder": 0,
                            "content": null
                        },
                        {
                            "typeName": "知识",
                            "typeValue": 1,
                            "parentName": "教学目标",
                            "isShow": true,
                            "showOrder": 1,
                            "content": null
                        },
                        {
                            "typeName": "能力",
                            "typeValue": 2,
                            "parentName": "教学目标",
                            "isShow": true,
                            "showOrder": 2,
                            "content": null
                        },
                        {
                            "typeName": "思政目标",
                            "typeValue": 3,
                            "parentName": "教学目标",
                            "isShow": true,
                            "showOrder": 3,
                            "content": null
                        },
                        {
                            "typeName": "概述",
                            "typeValue": 4,
                            "parentName": "考核办法",
                            "isShow": false,
                            "showOrder": 4,
                            "content": null
                        }
                    ]
                }
        :return:
        """

        url = url + "/courseApi/v1/coursechaptergoal"

        r = requests.post(url=url, headers=headers, params=params, json=json)

        return r

    @classmethod
    def get_course_chapter_goal_type(cls, url: str, headers, params):
        """
        @summary:获取章节目标分类
        @description:云课堂教师端-课程建设使用
        :param url:
        :param headers:
        :param params:validCode:&signKey=123123
        :return:object:{
                            "typeName": "概述", #类型名称
                            "typeValue": 0,# 类型值
                            "parentName": "教学目标", #父级类型名称
                            "isShow": false, # 是否展示
                            "showOrder": 0 # 排序字段
                        }
        """
        url = url + "/courseApi/v1/coursechaptergoal/type"

        r = requests.get(url=url,headers=headers,params=params)

        return r
